@layout("../../system/layout.html", {title: "操作权限-角色管理"}){
<ul id="menuTree" class="ztree"></ul>
<script type="text/javascript">
    var setting = {
        data: {
            simpleData: {
                enable: true,
                idKey: "menuId",
                pIdKey: "parentId",
                rootPId: 0
            },
            key: {
                url: "nourl"
            }
        },
        check: {
            enable: true,
            nocheckInherit: true
        }
    };
    var ztree;

    var vm = new Vue({
        el: '#dpLTE',
        data: {
            role: {}
        },
        methods: {
            getMenu: function (menuId) {
                $.ajax({
                    type: 'get',
                    async: false,
                    contentType: 'application/json',
                    url: '../../sys/menu/list?_' + $.now(),
                    data: null,
                    success: function (r) {
                        ztree = $.fn.zTree
                            .init($("#menuTree"), setting, r);
                        ztree.expandAll(true);
                    },
                    dataType: 'json'
                });
            },
            setForm: function () {
                this.getMenu();
                $.SetForm({
                    url: '../../sys/role/info',
                    param: vm.role.roleId,
                    success: function (data) {
                        vm.role = data;
                        //勾选角色所拥有的菜单
                        var menuIds = vm.role.menuIdList;
                        for (var i = 0; i < menuIds.length; i++) {
                            var node = ztree.getNodeByParam("menuId", menuIds[i]);
                            ztree.checkNode(node, true, false);
                        }
                    }
                });
            },
            acceptClick: function () {
                var nodes = ztree.getCheckedNodes(true);
                var menuIdList = new Array();
                for (var i = 0; i < nodes.length; i++) {
                    menuIdList.push(nodes[i].menuId);
                }
                vm.role.menuIdList = menuIdList;
                $.ConfirmForm({
                    url: '../../sys/role/authorize/opt?_' + $.now(),
                    param: vm.role,
                    success: function (data) {
                    }
                });
            }
        }
    })
</script>
@}